package com.chalmers.irc2you.model;

import java.util.LinkedList;


/**
 * The implementation of a channel
 * @author printz
 *
 */
public class Channel {

	private String name;
	private LinkedList<Message> messages;
	private int placement;
	private boolean read;
	private String updated;

	/**
	 * Public constructor
	 * @param name the name of the channel
	 * @param messages a list of all the messages in the channel
	 * @param placement the placement of the channel in irssi
	 * @param read a boolean that tells us if the channel has messages that hasn't been read
	 */
	public Channel( String name, LinkedList<Message> messages) {
		this.name = name;
		this.messages = messages;
		this.placement = placement;
		this.read = false;
		this.updated = null;
	}

	
	/**
	 * Sets the latest time this channel was updated
	 * @param time The time this channel was updated
	 */
	protected void setUpdate(String time){
		this.updated = time;
	}
	/**
	 * Get the latest time this channel was updated
	 * @return
	 */
	public String getUpdate(){
		return updated;
	}
	/**
	 * @return the name of the channel
	 */
	public String getName(){
		return new String(name);
	}
	
	/**
	 * @return the messages in the channel
	 */
	public LinkedList<Message> getMessages(){
		return messages;
	}
	
	/**
	 * @return returns the placement of the channel in irssi
	 */
	public int getPlacement(){
		int place = placement;
		return place;
	}
	
	/**
	 * @return false if there are messages that haven't been read
	 */
	public boolean isRead(){
		return new Boolean(read);
	}
	/**
	 * set if the channel is read
	 * @param read true if the channel is read
	 */
	public void setRead(Boolean read){
		this.read = read;
	}
	/**
	 * 
	 * @param msg The new message that is to be added to the channel
	 */
	public void addMessage(Message msg){
		messages.add(msg);
	}
}
